<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css"/>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css"/>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/jquery.confirm.css"/>
		<style>
		.nPass{
		background-color:rgb(236, 188, 149);
		}
		.pass {
			background-color: #95CFEC;
		}
		
		</style>
	</head>
	<body>
		<div class="am-g">
			<br>
			<div class="am-u-md-9 am-cf" style="position: fixed;top:0;background-color:#fff; z-index:100;width:100%">
       		<p></p><span id="timeout" style="color:red;font-size:30px;">{$timeout}</span>秒后刷新
			<input value=""  style="width:180px;margin-left: 100px;" placeholder="立即对话" type="text" id="immediately" name="immediately" class="field">
			<button  type="button" onClick="immediately_comment()" id="immediately_html"  class="am-btn-default"> 立即对话</button>
			<p style="font-size:20px;">浏览量:<strong style="font-size:25px;color:#0e90d2"> {$pv|default:'0'} </strong>
				登陆量:<strong style="font-size:25px;color:#0e90d2"> {$uv|default:'0'} </strong>
				现弹幕池数量:<strong style="font-size:25px;color:#0e90d2"> {$lastCycleNum|default:0}</strong>
				下一周期弹幕池数量:<strong style="font-size:25px;color:#0e90d2"> {$passCount|default:0}</strong>
				审核库总数量:<strong style="font-size:25px;color:#0e90d2"> {$count|default:0}</strong>
			</p>
		        
      	</div>
  <br>
      
      
      <div class="am-g" >
      <div class="am-u-sm-12" style="margin-top:145px;">
        <form class="am-form" >
          <table class="am-table table-main">
            <thead>
              <tr style="position: fixed;top:135px;background-color:#fff;width:100%;">
                <th width="5%" class="table-check"><input id="qx" onclick="ckAll()" type="checkbox" >全选</th>
				<th width="10%" class="table-type">昵称</th>
				<th width="35%" class="table-type">评论</th>
				<th width="10%" class="table-type">状态</th>
				<th width="10%" class="table-type">加精</th>
				<th width="10%" class="table-author">提交时间</th>
				<th width="15%" class="table-author">操作</th>
				
              </tr>
          </thead>
          <tbody style="margin-top:140px;">
          	   <!--{foreach key=key from=$sql_list item=sql}-->
            <tr {if $sql.status eq 2}class="nPass"{/if} >
              <td width="5%"><input onchange="changeColor(this)" type="checkbox" name="commentsIds" id="commentsId_{$sql.id}" value="{$sql.id}"></td>
              <td width="10%" onClick="checkedthis(this)">{$sql.nickname}</td>
              <td width="35%" onClick="checkedthis(this)">{$sql.comment|default:" - "}</td>
			  <td width="10%" onClick="checkedthis(this)"> {$sql.statusShow|default:" - "}</td>
			  <td width="10%"><input {if $sql.addStatus==1}checked=checked{/if} type="checkbox" onclick="addDigest({$sql.id},this)" name="addStatus"></td>
			  <td width="10%" onClick="checkedthis(this)">{$sql.addtime|date_format:"Y-m-d"}</td>
     		  <td width="15%"><div><div><a onclick="silence({$sql.wxid})" >禁止该用户发言    </a><a data-param ="{ url:'index.php?g=admin&m=chat&a=delRecord&id={$sql.id}',hide:4}" class=" am-btn-xs am-text-danger hy-js-del" > 删除</a></div></div></td>
            </tr>
              <!--{/foreach}-->  
          </tbody>
        </table>
          <div class="am-cf">

  <div class="am-fr" style="margin-right:300px">
    <span>共{$count|default:0}条记录 - </span>
								{$list_page}
  </div>
</div>
          <hr />
      
        </form>
      </div>

    </div>
	
			<div class="am-fl am-cf" style="position: fixed;left:0%;padding-left:20%;top:90%;background-color:#fff; z-index:100;width:100%;bottom:1%;">
	          <div class="am-btn-toolbar am-fl">
	            <div class="am-btn-group am-btn-group-xs">
	              <a  href="javascript:void(0);" onclick="batchPass()" id="pass_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 批量通过</a>
	            </div>
				<div class="am-btn-group am-btn-group-xs">
	              <a  href="javascript:void(0);" onclick="batchNopass()" id="Nopass_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 批量不通过</a>
	            </div>
				<div class="am-btn-group am-btn-group-xs">
	              <a  href="javascript:void(0);" onclick="updateStatus()" id="status_html" class="am-btn am-btn-default hy-js-href"><span  class="am-icon-plus"></span>{if $status}{if $status eq 0} 旁路已关闭{else} 旁路已开启{/if}{else} 旁路已关闭{/if}</a>
				  <input value="{$status|default:0}" type="hidden" id="status">
	            </div>
				<div class="am-btn-group am-btn-group-xs">
	              <a  href="javascript:void(0);" onclick="cleanChatPool()" id="chat_html" class="am-btn am-btn-default hy-js-href"><span  class="am-icon-plus"></span> 一键清空弹幕池</a>
	            </div>
				<div class="am-btn-group am-btn-group-xs">
	              <a  href="javascript:void(0);" onclick="addDigestPool()" id="add_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 一键加精添加至审核池</a>
	            </div>
				<div class="am-btn-group am-btn-group-xs">
	              <a  href="javascript:void(0);" onclick="refreshNow()" id="refresh_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 刷新</a>
	            </div>
	          </div>
	        </div>
	
	
	
    </div>
{include file='../Common/hy_footer.html'}
<script src="{$_C.hy_path}js/jquery.confirm.js"></script>
	<script type="text/javascript">
		var page='{$page}';
		//var timeout = parseInt('{$timeout}');
		var  inter;
		var now = parseInt('{$now}');
		var timestamp = parseInt('{$timestamp}');
		var refresh = parseInt('{$refreshtime}');
		var timeout = refresh-(now-timestamp)%refresh;
		var isBusy = false;
		function checkedthis(params){
			if($(params).parent().find("input[name=commentsIds]").attr("checked")!="checked"){
				$(params).parent().find("input[name=commentsIds]").prop("checked","checked");
				$(params).parent().addClass('pass');
			}else{
				$(params).parent().find("input[name=commentsIds]").prop('checked',"");
				$(params).parent().removeClass('pass');
			}
		}
		function changeColor(params){
			if($(params).parent().parent().hasClass('pass')){
				$(params).parent().parent().removeClass('pass');
			}else{
				$(params).parent().parent().addClass('pass');
			}
			
		}
		function commentsPass(obj,id){
//			$(obj).html();
			
		}
		$(function(){
				inter = setInterval('countDown()',1000);
		})
		function countDown(){
			timeout--;
			$("#timeout").html(timeout);
			if (timeout<=0) {
				clearInterval(inter);
				var status = $("#status").val();
				var url = "index.php?g=admin&m=rchat&a=update&status="+status;
				$.post(url,"",function(data){
					if(data.error==1){
						$('.hy-js-linkarea').html(data.content);
						window.location.href="index.php?g=admin&m=rchat&a=index";
					}else{
						alert(data.content);
					}
				},"json")
			}else{
				
			}
		}
		function refreshNow(){
			$("#refresh_html").html("<span class='am-icon-plus'></span> 刷新中...");
			parent.$('#revision-check').attr('src', parent.$('#revision-check').attr('src'));
		}
		function jq_confirm(title,message,func){
				$.confirm({
				'title'		: title,
				'message'	: message,
				'buttons'	: {
					'是'	: {
						'class'	: 'blue',
						'action': function(){
							func();
							$.confirm.hide();
						}
					},
					'否'	: {
						'class'	: 'gray',
						'action': function(){
							$.confirm.hide();
						}	// Nothing to do in this case. You can as well omit the action property.
					}
				}
			});
		}
		function batchPass(){
			$("#pass_html").html("<span class='am-icon-plus'></span> 处理中...");
			isBusy = true;
			var uids = "";
			if ($("input[name='commentsIds']:checked").length > 0) {
				$("input[name='commentsIds']:checked").each(function() {
					uids += "," + $(this).val();
				})
				uids = uids.substring(1);
			} else {
				$("#pass_html").html("<span class='am-icon-plus'></span> 批量通过");
				return;
			}
			var url = "index.php?g=admin&m=rchat&a=batchPass";
			var data = {
				uids:uids
			}
			$.post(url,data,function(data){
				if(data.error==1){
					$('.hy-js-linkarea').html(data.content);
					//alert(data.content);
					window.location.href="index.php?g=admin&m=rchat&a=index&page="+page;
				}else{
					//alert(data.content);
				}
				isBusy = false;
				$("#pass_html").html("<span class='am-icon-plus'></span> 批量通过");
			},"json"
			)
		}
		function batchNopass(){
			$("#Nopass_html").html("<span class='am-icon-plus'></span> 处理中...");
			isBusy = true;
			var uids = "";
			if ($("input[name='commentsIds']:checked").length > 0) {
				$("input[name='commentsIds']:checked").each(function() {
					uids += "," + $(this).val();
				})
				uids = uids.substring(1);
			} else {
				$("#Nopass_html").html("<span class='am-icon-plus'></span> 批量不通过");
				return;
			}
			var url = "index.php?g=admin&m=rchat&a=batchNopass";
			var data = {
				uids:uids
			}
			$.post(url,data,function(data){
				if(data.error==1){
					$('.hy-js-linkarea').html(data.content);
					//alert(data.content);
					window.location.href="index.php?g=admin&m=rchat&a=index&page="+page;
				}else{
					//alert(data.content);
				}
				isBusy = false;
				$("#Nopass_html").html("<span class='am-icon-plus'></span> 批量不通过");
			},"json"
			)
		}
		
		function ckAll(){
			var qx = $("#qx");
			$("input[name='commentsIds']").each(function() {
					$(this).prop('checked', qx.prop('checked'));
					if(qx.prop('checked')){
						$(this).parent().parent().addClass('pass');
					}else{
						$(this).parent().parent().removeClass('pass');
					}
				})
		}
		
		function silence(wxid){
		jq_confirm2("提醒","确定禁言该用户？",function(status){
			var data = {
				"status":status,
				"wxid":wxid
			}
			var url = "index.php?g=admin&m=rchat&a=silenceUser";
			$.post(url,data,function(res){
				if(res.error==1){
						alert(res.content);
					}else{
						alert(res.content);
					}
			},"json")
		})
	}
	function jq_confirm2(title,message,func){
				$.confirm({
				'title'		: title,
				'message'	: message,
				'buttons'	: {
					'禁言1小时'	: {
						'class'	: 'blue',
						'action': function(){
							func(1);
							$.confirm.hide();
						}
					},
					'禁言5天'	: {
						'class'	: 'blue',
						'action': function(){
							func(2);
							$.confirm.hide();
						}
					},
					'取消'	: {
						'class'	: 'gray',
						'action': function(){
							$.confirm.hide();
						}	// Nothing to do in this case. You can as well omit the action property.
					}
				}
			});
		}
		
	function updateStatus(){
		isBusy = true;
			var status = $("#status").val();
			if(status==1){
				status = 0;
				$("#status_html").html("<span  class='am-icon-plus'></span> 旁路关闭中");
			}else{
				status = 1;
				$("#status_html").html("<span  class='am-icon-plus'></span> 旁路开启中");
			}
			var url = "index.php?g=admin&m=rchat&a=updatestatus&status="+status;
				$.post(url,"",function(data){
						if(status=='1'){
							$("#status").val(1);
							$("#status_html").html("<span  class='am-icon-plus'></span> 旁路已开启");
						}else{
							$("#status").val(0);
							$("#status_html").html("<span  class='am-icon-plus'></span> 旁路已关闭");
						}
						isBusy = false;
				},"text")
		}
		function addDigest(id,params){
				var url = "index.php?g=admin&m=rchat&a=addDigest";
				var data={
					'id':id
				}
				$.post(url,data,function(res){
					if(res.error==0){
						
					}else{
						params.checked=false;
						alert(res.content);
					}
				},'json');
		}
		function cleanChatPool(){
			$("#pass_html").html("<span class='am-icon-plus'></span> 清空中...");
			var url ="index.php?g=admin&m=rchat&a=cleanChatPool";
			$.post(url,"",function(res){
				if(res.error==0){
					window.location.href="index.php?g=admin&m=rchat&a=index";
//					window.history.go(0);
				}else{
					alert(res.content);
				}
				$("#pass_html").html("<span class='am-icon-plus'></span> 一键清空弹幕池");
			},'json')
		}
		
		function addDigestPool(){
			$("#add_html").html("<span class='am-icon-plus'></span> 一键添加中...");
			var url ="index.php?g=admin&m=rchat&a=addDigestPool";
			$.post(url,"",function(res){
				if(res.error==0){
					//alert(res.content);
					window.location.href="index.php?g=admin&m=rchat&a=index";	
				}else{
					alert(res.content);
				}
			$("#add_html").html("<span class='am-icon-plus'></span> 一键加精添加至弹幕池");
			},'json')
		}
		function immediately_comment(){
			if(isBusy){
				return false;
			}
			isBusy = true;
			var immediately = $("#immediately").val();
			if(immediately==undefined||immediately==null||immediately==""){
				$("#immediately_html").html("对话内容为空");
				setTimeout(function(){
					$("#immediately_html").html("立即对话");
					isBusy = false;
				},1000);
				return false;
			}
			var data = {
				immediately:immediately
				};
			var url ="index.php?g=admin&m=rchat&a=saveImmediately";
			$.post(url,data,function(res){
				if(res.error==0){
					$("#immediately_html").html(res.content);
					$("#immediately").val("");
				}else{
					$("#immediately_html").html(res.content);
				}
				setTimeout(function(){
						$("#immediately_html").html("立即对话");
						isBusy = false;
				},1000);
			},'json')
			
		}
	</script>
	
	</body>
</html>
